package com.pactera.jep.service.yapin.eval.value.controller;

import com.alibaba.fastjson.JSONObject;
import com.pactera.jep.web.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import com.pactera.jep.orm.Filter;
import com.pactera.jep.orm.Order;
import com.pactera.jep.orm.Page;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.pactera.jep.web.controller.CrudController;
import org.springframework.web.bind.annotation.*;

import com.pactera.jep.service.yapin.eval.value.model.EvalProcessCltDetails;
import com.pactera.jep.service.yapin.eval.value.service.EvalProcessCltDetailsService;


/**
 *
 * @Author YouName
 * @Date 2020-7-20 10:33:35
 */
@RestController
@RequestMapping("/evalProcessCltDetails")
@Api(description = "估值流程押品明细信息表")
public class EvalProcessCltDetailsController extends CrudController<EvalProcessCltDetails> {

    @Autowired
    EvalProcessCltDetailsService evalProcessCltDetailsService;

    @GetMapping("/{id}")
    @ApiOperation("查询估值流程押品明细信息表")
    public Result get(@PathVariable("id") String evalProDetailsId) {
        return Result.success(evalProcessCltDetailsService.get(evalProDetailsId));
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除估值流程押品明细信息表")
    public Result delete(@PathVariable("id") String evalProDetailsId) {
        return Result.success(evalProcessCltDetailsService.deleteByPrimaryKey(evalProDetailsId));
    }

    @PostMapping("/save")
    @ApiOperation("插入估值流程押品明细信息表")
    public Result insert(@RequestBody EvalProcessCltDetails evalProcessCltDetails) {
        return Result.success(evalProcessCltDetailsService.insert(evalProcessCltDetails));
    }

    @PostMapping("/update")
    @ApiOperation("更新估值流程押品明细信息表")
    public Result update(@RequestBody EvalProcessCltDetails evalProcessCltDetails) {
        return Result.success(evalProcessCltDetailsService.update(evalProcessCltDetails));
    }

    @PostMapping("/getList")
    @ApiOperation("获取待评估列表")
    public Map<String,Object> getList(@RequestBody JSONObject object){
        try {
            return evalProcessCltDetailsService.getList(object);

        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 为列表页面做数据准备
     */
    @Override
    protected void prepareQuery(Page<EvalProcessCltDetails> page, List<Filter> filters, List<Order> orders, HttpServletRequest    request) {
        evalProcessCltDetailsService.query(page, filters, orders);
    }
}
